package utils;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

public class App7 {
    public static void main(String[] args) {
        App7 app7 = new App7();
        app7.listDemo();
    }

    public void listDemo(){
        Stu stu1 = new Stu(1,"a");
        Stu stu2 = new Stu(2,"b");
        Stu stu3 = new Stu(3,"c");
        Stu stu4 = new Stu(4,"d");
        Stu stu5 = new Stu(5,"e");
        List<Stu> stuList = new LinkedList<Stu>();
        stuList.add(stu1);
        stuList.add(stu2);
        stuList.add(stu3);
        stuList.add(stu4);
        stuList.add(stu5);
        List<Integer> idList = stuList.stream().map(stu -> {
            return stu.id;
        }).collect(Collectors.toList());
        List<Stu> stuList1 = stuList.stream().filter(stu -> stu.getId()==1).collect(Collectors.toList());
        System.out.println("idList = " + idList.toString());
        stuList1.forEach(stu -> {
            System.out.println("stu.getId() = " + stu.getId() + " && stu.getName() = " + stu.getName());
        });
    }

    public class Stu{
        private int id;
        private String name;

        public Stu(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
